// Logic 247: Death handler

#include "defines.txt"
#define death_music_completed f254

if (death_type == just_died) {
  disable.item(menu_save);
  disable.item(menu_seeobject);
  disable.item(menu_normalspeed);
  disable.item(menu_fastestspeed);
  disable.item(menu_fastspeed);
  disable.item(menu_slowspeed);
  accept.input();
  cancel.line();
  program.control();
  clear.lines(23, 24, 0);

  print("The dynamite blew up in your hands without warning because you accidentally ignited the base of the fuse! You shouldn't have tried to light the fuse while holding the stick of dynamite in your hands.");

  death_type = dead;
  load.sound(death_music);
  sound(death_music, death_music_completed);
}

if (death_music_completed) {
  reset(death_music_completed);
  print("Thank you for playing AGI Quest I. At this point, you can either Restore, Restart or Quit.");
}

if (controller(key_activate_menu)) {
  menu.input();
}

if ((controller(menu_help) ||
     said("help"))) {
  call(help_screen);
}

if ((controller(menu_restore) ||
     said("restore", "game") ||
     said("restore"))) {
  restore.game();
}

if ((controller(menu_restart) ||
     said("restart", "game") ||
     said("restart"))) {
  restart.game();
}

if ((controller(menu_inventory) ||
     said("inventory"))) {
  status();
}

if ((controller(menu_quit) ||
     said("quit"))) {
  stop.sound();
  quit(0);
}

if (controller(menu_about)) {
  call(about_game);
}

if (controller(menu_soundonoff)) {
  toggle(sound_on);
}

if (input_received) {
  print("At this point, you should restore a previously saved game, restart the game from the beginning or quit the game.");
}

return();